/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('nbftestpop', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model AddRequest {
  arg0?: int32(name='arg0'),
  arg1?: int32(name='arg1'),
}

model AddResponseBody = {
  sum?: int32(name='sum'),
}

model AddResponse = {
  headers: map[string]string(name='headers'),
  body: AddResponseBody(name='body'),
}

async function add(request: AddRequest): AddResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return addWithOptions(request, headers, runtime);
}

async function addWithOptions(request: AddRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AddResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.arg0)) {
    query.arg0 = request.arg0;
  }
  if (!Util.isUnset(request.arg1)) {
    query.arg1 = request.arg1;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  return doROARequest('Add', '2021-08-31_22-30-06-136', 'HTTPS', 'POST', 'AK', `/kxNineThreeNineSeven/kxAddTest`, 'json', req, runtime);
}

model AddAssetRequest {
  x?: int32(name='x'),
  y?: int32(name='y'),
}

model AddAssetResponseBody = {
  sum?: int32(name='sum'),
}

model AddAssetResponse = {
  headers: map[string]string(name='headers'),
  body: AddAssetResponseBody(name='body'),
}

async function addAsset(request: AddAssetRequest): AddAssetResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return addAssetWithOptions(request, headers, runtime);
}

async function addAssetWithOptions(request: AddAssetRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AddAssetResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.x)) {
    query.x = request.x;
  }
  if (!Util.isUnset(request.y)) {
    query.y = request.y;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  return doROARequest('AddAsset', '2021-08-31_22-30-06-136', 'HTTPS', 'POST', 'AK', `/asset/add`, 'json', req, runtime);
}

model TestAssetRequest {
  x?: int32(name='x'),
  y?: int32(name='y'),
}

model TestAssetResponseBody = {
  sum?: int32(name='sum'),
}

model TestAssetResponse = {
  headers: map[string]string(name='headers'),
  body: TestAssetResponseBody(name='body'),
}

async function testAsset(request: TestAssetRequest): TestAssetResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return testAssetWithOptions(request, headers, runtime);
}

async function testAssetWithOptions(request: TestAssetRequest, headers: map[string]string, runtime: Util.RuntimeOptions): TestAssetResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.x)) {
    query.x = request.x;
  }
  if (!Util.isUnset(request.y)) {
    query.y = request.y;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  return doROARequest('TestAsset', '2021-08-31_22-30-06-136', 'HTTPS', 'POST', 'AK', `/test/url/a`, 'json', req, runtime);
}

